// ============================================================================
// Table Module Styles
// - Enhanced data table styles
// - Table toolbar, pagination, actions
// - Responsive table design
// ============================================================================

// ------------------------------
// Enhanced Data Table
// ------------------------------

.enhanced-data-table {
  background: var(--el-bg-color);
  border-radius: var(--border-radius-large);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  overflow: hidden;

  // Table header
  .table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--el-border-color-lighter);
    background: var(--el-fill-color-light);

    .table-title {
      font-size: 16px;
      font-weight: 600;
      color: var(--el-text-color-primary);
      display: flex;
      align-items: center;
      gap: 8px;

      .title-icon {
        color: var(--el-color-primary);
      }
    }

    .table-subtitle {
      font-size: 12px;
      color: var(--el-text-color-secondary);
      margin-top: 2px;
    }

    .table-meta {
      display: flex;
      align-items: center;
      gap: 16px;
      font-size: 14px;
      color: var(--el-text-color-secondary);

      .meta-item {
        display: flex;
        align-items: center;
        gap: 4px;
      }
    }
  }

  // Toolbar area
  .table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--el-border-color-lighter);
    gap: 16px;

    .toolbar-left {
      flex: 1;
      display: flex;
      align-items: center;
      gap: 12px;
      min-width: 0;
    }

    .toolbar-right {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-shrink: 0;
    }

    .search-box {
      max-width: 300px;
      min-width: 200px;
    }

    .filter-tags {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
    }
  }

  // Batch operations bar
  .batch-operations {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--el-color-primary-light-9);
    border-bottom: 1px solid var(--el-color-primary-light-7);

    .batch-info {
      font-size: 14px;
      color: var(--el-text-color-regular);

      strong {
        color: var(--el-color-primary);
        font-weight: 600;
      }
    }

    .batch-actions {
      display: flex;
      gap: 8px;
    }

    .batch-cancel {
      margin-left: 12px;
    }
  }

  // Table content
  .table-content {
    overflow-x: auto;

    .el-table {
      border-radius: 0;

      // Table header styling
      .el-table__header {
        background: var(--el-fill-color-lighter);
        
        th {
          background: transparent !important;
          border-bottom: 1px solid var(--el-border-color-light);
          font-weight: 600;
          color: var(--el-text-color-primary);
          font-size: 14px;
          padding: 12px 16px;

          .cell {
            white-space: nowrap;
          }
        }
      }

      // Table body styling
      .el-table__body {
        tr {
          transition: background-color 0.2s ease;

          &:hover {
            background: var(--el-fill-color-light) !important;
          }

          td {
            border-bottom: 1px solid var(--el-border-color-lighter);
            padding: 12px 16px;
            font-size: 14px;

            .cell {
              line-height: 1.5;
            }
          }
        }
      }

      // Remove default borders
      &::before {
        display: none;
      }

      .el-table__border-left-patch {
        display: none;
      }
    }
  }

  // Table footer with pagination
  .table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-top: 1px solid var(--el-border-color-lighter);
    background: var(--el-fill-color-light);

    .footer-info {
      font-size: 14px;
      color: var(--el-text-color-secondary);
    }

    .el-pagination {
      margin: 0;
    }
  }
}

// ------------------------------
// Table Actions
// ------------------------------

.table-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;

  .el-button {
    margin: 0;
    padding: 4px 8px;
    font-size: 12px;
    line-height: 1.5;

    &.action-edit {
      color: var(--el-color-primary);
      border-color: var(--el-color-primary);
    }

    &.action-delete {
      color: var(--el-color-danger);
      border-color: var(--el-color-danger);
    }

    &.action-view {
      color: var(--el-color-info);
      border-color: var(--el-color-info);
    }
  }

  .action-dropdown {
    .el-dropdown-link {
      color: var(--el-text-color-secondary);
      cursor: pointer;
      transition: color 0.2s ease;

      &:hover {
        color: var(--el-color-primary);
      }
    }
  }

  // Compact mode
  &.actions-compact {
    gap: 4px;

    .el-button {
      padding: 2px 6px;
      font-size: 11px;
    }
  }
}

// ------------------------------
// Column Settings Panel
// ------------------------------

.column-settings {
  .settings-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--el-border-color-lighter);
    font-weight: 500;
    color: var(--el-text-color-primary);
  }

  .settings-content {
    max-height: 300px;
    overflow-y: auto;
    padding: 8px;
  }

  .column-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: var(--border-radius-base);
    cursor: pointer;
    transition: background-color 0.2s ease;

    &:hover {
      background: var(--el-fill-color-light);
    }

    .column-checkbox {
      margin: 0;
    }

    .column-label {
      flex: 1;
      margin-left: 8px;
      font-size: 14px;
    }

    .column-handle {
      color: var(--el-text-color-placeholder);
      cursor: move;
    }
  }

  .settings-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--el-border-color-lighter);
    text-align: right;
  }
}

// ------------------------------
// Quick Filters
// ------------------------------

.quick-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;

  .filter-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: var(--el-fill-color-light);
    border-radius: var(--border-radius-base);
    font-size: 12px;
    color: var(--el-text-color-regular);
    cursor: pointer;
    transition: all 0.2s ease;

    &:hover {
      background: var(--el-fill-color);
      color: var(--el-text-color-primary);
    }

    &.active {
      background: var(--el-color-primary-light-9);
      color: var(--el-color-primary);
      border: 1px solid var(--el-color-primary-light-7);
    }

    .filter-label {
      font-weight: 500;
    }

    .filter-value {
      margin-left: 4px;
    }

    .filter-remove {
      margin-left: 4px;
      cursor: pointer;
      color: var(--el-text-color-placeholder);

      &:hover {
        color: var(--el-color-danger);
      }
    }
  }

  .clear-filters {
    color: var(--el-color-danger);
    font-size: 12px;
    cursor: pointer;
    text-decoration: underline;

    &:hover {
      color: var(--el-color-danger-dark-2);
    }
  }
}

// ------------------------------
// Table Status Indicators
// ------------------------------

.table-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--border-radius-base);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;

  &.status-active {
    color: var(--el-color-success);
    background: var(--el-color-success-light-9);
  }

  &.status-inactive {
    color: var(--el-color-info);
    background: var(--el-color-info-light-9);
  }

  &.status-pending {
    color: var(--el-color-warning);
    background: var(--el-color-warning-light-9);
  }

  &.status-disabled {
    color: var(--el-color-danger);
    background: var(--el-color-danger-light-9);
  }

  &.status-draft {
    color: var(--el-text-color-secondary);
    background: var(--el-fill-color);
  }

  .status-icon {
    font-size: 10px;
  }
}

// ------------------------------
// Empty State in Tables
// ------------------------------

.table-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;

  .empty-icon {
    font-size: 64px;
    color: var(--el-color-info-light-3);
    margin-bottom: 16px;
  }

  .empty-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--el-text-color-regular);
    margin-bottom: 8px;
  }

  .empty-description {
    font-size: 14px;
    color: var(--el-text-color-secondary);
    margin-bottom: 16px;
    line-height: 1.5;
  }

  .empty-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
  }
}

// ------------------------------
// Table Loading State
// ------------------------------

.table-loading {
  position: relative;
  min-height: 200px;

  .loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;

    .loading-content {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 12px;

      .loading-text {
        font-size: 14px;
        color: var(--el-text-color-secondary);
      }
    }
  }
}

// ------------------------------
// Responsive Design
// ------------------------------

@media (max-width: 768px) {
  .enhanced-data-table {
    .table-header {
      flex-direction: column;
      align-items: stretch;
      gap: 12px;
      padding: 12px;

      .table-meta {
        justify-content: center;
      }
    }

    .table-toolbar {
      flex-direction: column;
      align-items: stretch;
      gap: 12px;
      padding: 12px;

      .toolbar-left,
      .toolbar-right {
        justify-content: center;
      }

      .search-box {
        max-width: none;
        min-width: 0;
      }
    }

    .batch-operations {
      flex-direction: column;
      align-items: stretch;
      gap: 12px;
      text-align: center;
      padding: 12px;

      .batch-actions {
        justify-content: center;
      }
    }

    .table-footer {
      flex-direction: column;
      gap: 12px;
      text-align: center;
      padding: 12px;
    }

    .table-actions {
      justify-content: center;
      gap: 4px;

      .el-button {
        font-size: 11px;
        padding: 2px 6px;
      }
    }
  }

  .quick-filters {
    justify-content: center;

    .filter-item {
      font-size: 11px;
      padding: 3px 6px;
    }
  }
}

// ------------------------------
// Print Styles
// ------------------------------

@media print {
  .enhanced-data-table {
    box-shadow: none;
    border: 1px solid #000;

    .table-toolbar,
    .batch-operations,
    .table-actions,
    .column-settings {
      display: none !important;
    }

    .table-header {
      border-bottom: 2px solid #000;
    }

    .table-content .el-table {
      .el-table__header th {
        background: #f5f5f5 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
      }

      .el-table__body tr:nth-child(even) {
        background: #f9f9f9 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
      }
    }

    .table-footer {
      border-top: 2px solid #000;
      
      .el-pagination {
        display: none !important;
      }
    }
  }
}
